package com.czkj.hwz.decorate.control;

import android.content.Context;


import com.czkj.hwz.decorate.IMP.HttpDoImp;
import com.czkj.hwz.decorate.base.HttpUrl;
import com.czkj.hwz.decorate.bean.User;

import org.xutils.common.Callback;
import org.xutils.http.RequestParams;
import org.xutils.x;

/**
 * Created by Administrator on 2017/10/5.
 */

public class UserCtl {
    private RequestParams mRequestParams;
    private Context mContext;
    private HttpDoImp httpDoImp;
    public UserCtl(RequestParams requestParams, Context context) {
        mRequestParams = requestParams;
        mContext = context;
    }

    public UserCtl(Context context) {
        mContext = context;
        this.httpDoImp = (HttpDoImp) context;
    }
    public void userRegister(final User user){
        mRequestParams=new RequestParams(HttpUrl.USER_REGISTER);
        mRequestParams.addBodyParameter("account",user.getAccount());
        mRequestParams.addBodyParameter("password",user.getPassword());
        mRequestParams.addBodyParameter("smscode",user.getSmscode());

        x.http().post(mRequestParams, new Callback.CommonCallback<String>() {
            @Override
            public void onSuccess(String result) {
                httpDoImp.onSuccess("userRegister",result);
            }

            @Override
            public void onError(Throwable ex, boolean isOnCallback) {
                httpDoImp.onError(ex.getMessage());
            }

            @Override
            public void onCancelled(CancelledException cex) {

            }

            @Override
            public void onFinished() {

            }
        });
    }

}
